package com.efast.dmom.mgmt.service.master.impl;

import com.efast.cafe.framework.util.SpringWebUtils;
import com.efast.dmom.mgmt.dao.master.TrBasBomItemMapper;
import com.efast.dmom.mgmt.entity.master.TmBasBom;
import com.efast.dmom.mgmt.entity.master.TrBasBomItem;
import com.efast.dmom.mgmt.service.master.TmBasBomService;
import com.efast.dmom.mgmt.service.master.TrBasBomItemService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Xu Cong
 * @since 2018-09-19
 */
@Service
public class TrBasBomItemServiceImpl extends ServiceImpl<TrBasBomItemMapper, TrBasBomItem> implements TrBasBomItemService {
	@Autowired
	private TmBasBomService tmBasBomService;
	
	@Override
	public void save(TrBasBomItem trBasBomItem) {
		EntityWrapper<TmBasBom> wrapper = new EntityWrapper<>();
		TmBasBom tmBasBom = tmBasBomService.selectOne(wrapper.eq("tm_bas_bom_id", trBasBomItem.getBomId()));
		if(tmBasBom!=null) {
			trBasBomItem.setBomName(tmBasBom.getBomName());
		}
		trBasBomItem.setCreateTime(new Date());
		trBasBomItem.setCreateUser(SpringWebUtils.getRequestUser());
		trBasBomItem.setCompanyCode(SpringWebUtils.getRequestCompany());
		this.insert(trBasBomItem);
	}

}
